/**
 * 
 */
package com.cnc.fd;

import com.cnc.fd.hiber.FdCustomerConfig;

/**
 * @author 阿闲
 *
 */
public class CustomerConfig {

	public static int getPriority(String customer){
		
		FdCustomerConfig config = WsfdCache.getCustomerConfig(customer);
		
		if(config != null){
			return config.getPriority().intValue();
		}else{
			return Constants.DEFAULT_CUSTOMER_PRIORITY;
		}		
	}
	
	public static int getAllowUploadTaskCount(String customer){

		FdCustomerConfig config = WsfdCache.getCustomerConfig(customer);
		
		if(config != null){
			return config.getAllowUploadTaskCount().intValue();
		}else{
			return Constants.DEFAULT_CUSTOMER_UPLOAD_TASK_COUNT;
		}	
		
	}
	
	public static int getAllowOtherTaskCount(String customer){
		FdCustomerConfig config = WsfdCache.getCustomerConfig(customer);
		if(config != null){
			return config.getAllowOtherTaskCount().intValue();
		}else{
			return Constants.DEFAULT_CUSTOMER_OTHER_TASK_COUNT;
		}		
	}
	
	public static String isNewTaskFirst(String customer){
		FdCustomerConfig config = WsfdCache.getCustomerConfig(customer);
		if(config != null){
			return config.getNewTaskFirst();
		}else{
			return "N";
		}		
	}
	
	public static String isPurge(String customer){
		FdCustomerConfig config = WsfdCache.getCustomerConfig(customer);
		if(config != null){
			return config.getIsPurge(); 
		}else{
			return "N";
		}
		
	}
	
	public static long getAllowFailureCount(String customer){
		
		FdCustomerConfig config = WsfdCache.getCustomerConfig(customer);
		
		if(config != null){
			return config.getAllowFailureCount().longValue();
		}else{
			return 0;
		}
		
	}
	
	public static long getAllowDayUploadSyncCount(String customer){
		FdCustomerConfig config = WsfdCache.getCustomerConfig(customer);
		
		if(config != null){
			return config.getDayUploadSyncCount().longValue();
		}else{
			return Constants.DEFAULT_DAY_UPLOAD_SYNC_COUNT;
		}		
	}
	
	public static String getRootDir(String customer){
		FdCustomerConfig config = WsfdCache.getCustomerConfig(customer);
		if(config == null || config.getRootDir() == null){
			return "/home/ftpsite/" + customer + "/";
		}else{
			return config.getRootDir();
		}
		
	}
	
	public static void main(String[] args){
		System.out.println(getAllowOtherTaskCount("qqflv"));
	}
}
